<%@page import="com.portal4kids.model.ServicesArt"%>
<%@page import="com.portal4kids.controller.ServicesManager"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="stars/mx_stars.css" type="text/css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<link rel="stylesheet" href="css/search_style.css">
<script type="text/javascript" src="stars/mx_stars.js"></script>
<title>Portal for kids</title>
<script type="text/javascript">
$(document).ready(function(){
    $('#rate').stars();
});
</script>
</head>
<body background="images/bg_search.jpg">
<div id="top">
 <ul id=menu>
      <li><a href="index.jsp">home</a></li>
      <li><a href="baner/newses.jsp">aktualności</a></li>

      <li><a href=#>oceny</a></li>
      <li><a href="baner/aboutAs.jsp">o nas</a></li>
      <li><a href="baner/contact.jsp">kontakt</a></li>
    </ul>
</div>
<center style="color: white;">
<%

if(request.getParameter("rate") == null || request.getParameter("rate") == ""){


}
else{
	
	int rank = Integer.parseInt(request.getParameter("rate"));
	int id = Integer.parseInt(request.getParameter("id"));
	System.out.print("not null" + rank + " " + id);
	ServicesManager.addRankArt(id, rank);
}

%>

<h1>Szczegóły:</h1>

<%  int id = Integer.parseInt(request.getParameter("id")); %>
<%  ServicesManager man = new ServicesManager();
    List <ServicesArt> detailsServices = man.getArtDetails(id);
    int avarage = detailsServices.iterator().next().getAvarage();
    int lg = detailsServices.iterator().next().getNumberOfVotes();
%>
<div style="float: left; width: 70%; margin-left: 15%;">   
	<div style="float:left; width: 50%;">
		<div style="float: left; width: 100%;">
			<table>
			<tr>
				<td style="width: 200px; font-weight: bold;">Nazwa:</td>
				<td><%= detailsServices.iterator().next().getName() %> </td>
			</tr>
			<tr>
				<td>Godzina rozpoczęcia zajęć:</td>
				<td><%= detailsServices.iterator().next().getTime() %> </td>
			</tr>
			<tr>
				<td>Minimalny wiek dziecka:</td>
				<td><%= detailsServices.iterator().next().getAge() %> </td>
			</tr>
			<tr>
				<td>Ocena:</td>
				<td><%= avarage  %></td>
			</tr>
		</table>
		</div>
		
	</div>	
	
	
	
	<div style="float: right; ">
	
		<% 	String zrodlo = detailsServices.iterator().next().getId_art()+ "ArtProfilowe.jpg" ;
					String sciezka = "ftp://misiekmk:stfzv6095@ftp.misiekmk.linuxpl.info/portal4kids/" + zrodlo;
					System.out.println("Sciezka: " + sciezka);
			
				%>
				<img alt="Brak zdjecia" src="<%=sciezka%>"width="350px;" height="400px"> 
	          <form action="artDetails.jsp" method="GET">
	            <input name="rate" id="rate" value="<%out.print(avarage);%>" />(<%out.print(avarage);%>)
	            <input type="hidden" name="id" value="<% out.print(id); %>" />
	            <br/>
	            <br/>
	            <input type="submit" value="Głosuj"/>
	          </form>
	</div>
	<div style="float: left; width: 90%; margin-top: 5%; color: black; text-align: left;">
			<h3><%=detailsServices.iterator().next().getDescription() %></h3>
		</div>
</div> 
</center>
</body>
</html>